﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kingdoms.Territories;
using WCell.Constants.GameObjects;
using WCell.Core.Initialization;
using WCell.RealmServer;
using WCell.RealmServer.Entities;
using WCell.RealmServer.GameObjects;
using WCell.RealmServer.Guilds;
using WCell.Core.Timers;
using WCell.Constants;
using WCell.Constants.NPCs;
using WCell.RealmServer.NPCs;

namespace Kingdoms
{
    public static class KingdomNPCMgr
    {
        public static Dictionary<int, NPCDatabaseEntry> Guards = new Dictionary<int, NPCDatabaseEntry>();
        
        public static void Init()
        {
            foreach (GuildExtension guilds in KingdomGuildMgr.Guilds.Values)
            {
                Guild g = GuildMgr.GetGuild(guilds.Id);
                var id = GetGuardNPCEntry(g, GuardEnum.GuardBrute);
                BruteTemplate.CreateTemplate(id, g.Name);
            }
            
            
            
            NPCDatabaseEntry[] entries = null;
            entries = NPCDatabaseEntry.FindAll();

            foreach (NPCDatabaseEntry entry in entries)
            {
                Guards.Add(entry.Id, entry);
            }

            /*
            foreach (NPCDatabaseEntry entry in entries)
            {
                switch (entry.GuardType)
                {
                    case (int)GuardEnum.GuardBrute:
                        {
                            var guard = NPCMgr.GetEntry(100001);
                            guard.Creator = () => new GuardBrute();

                            KingdomGuard g = guard as KingdomGuard;
                            g.dbentry = entry;

                            Guards.Add(g.dbentry.Id, g);
                        }
                }
            }
             */
        }

        public static uint GetGuardNPCEntry(Guild guild, GuardEnum guardtype)
        {
            return(guild.Id * 5 + 1000 * 1000 + (uint)guardtype);
        }
    }
    
}
